<html>
<head><title>Mail</title></head>
<body>



<?php 

// open message file
$messagefile = fopen ("message", "r");
$subject=fgets($messagefile, 4096);
$message="";
while (!feof ($messagefile)) 
{
    $message=$message.fgets($messagefile, 4096);
}
fclose ($messagefile);

echo "<h1>$subject</h1>\n<p>$message</p>";


// open address file
$addressfile = fopen ("addresses.txt", "r");
$addresses="";
while (!feof ($addressfile)) 
{
    $address=fgets($addressfile, 4096);
	$address=str_replace(chr(10),"",$address); 
	$address=str_replace(chr(13),"",$address);
	$addresses=$addresses."\n".$address;
	echo "Send message to \"".$address."\"<br>";
	email("michael",$address,$subject, $message);
}
fclose ($addressfile);

$selfmessage=$subject."\n".$addresses."\n\n\n".$message;


email("michael","michael@michaelstoddart.com",$subject,$selfmessage);


?>

</body>
</html>